package com.umerclass.ui.anmo.three.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bumptech.glide.RequestManager;
import com.umerclass.R;
import com.umerclass.bean.anmo.three.DeviceBean;
import com.umerclass.frame.ui.recycleview.adapter.RecyclerviewBasicAdapter;
import com.umerclass.frame.ui.recycleview.base.ViewHolder;
import com.umerclass.frame.ui.recycleview.listener.OptListener;
import java.util.List;

/**
 * Created by jack
 */

public class JiQiSetTopAdapter extends RecyclerviewBasicAdapter<DeviceBean> {

    private OptListener optListener;
    private RequestManager glideRequestManager;
    private LinearLayout linear;

    public JiQiSetTopAdapter(Context context, List datas, int layoutId, RequestManager glideRequestManager,
                             OptListener optListener) {
        super(context, datas, layoutId);
        this.optListener = optListener;
        this.glideRequestManager = glideRequestManager;
    }

    public JiQiSetTopAdapter(Context context, List datas, int layoutId, OptListener optListener) {
        super(context, datas, layoutId);
        this.optListener = optListener;
    }

    @Override
    public void convert(ViewHolder holder, final DeviceBean bean, final int position) {
        LinearLayout linear = holder.getView(R.id.linear);
        TextView tv = holder.getView(R.id.tv);
        View view = holder.getView(R.id.view);
        tv.setText(bean.getDeviceNo());
        boolean select = bean.isSelect();
        if(select){
            tv.setTextColor(Color.rgb(194,36,43));
            view.setVisibility(View.VISIBLE);
        }else{
            tv.setTextColor(Color.rgb(33,33,33));
            view.setVisibility(View.GONE);
        }
        linear.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                optListener.onOptClick(v,position);
            }
        });
    }

}
